package com.softaria.spkiller.analyzer;

import java.util.Collection;

import com.softaria.spkiller.analyzer.dependency.DependencyProblemCollector;
import com.softaria.spkiller.analyzer.hierarchy.HierarchyProblemCollector;
import com.softaria.spkiller.analyzer.hierarchy.enclosed.EnclosedHierarchyProblemReporter;
import com.softaria.spkiller.layers.LayerIdentifier;
import com.softaria.spkiller.metadata.ClassIdentifier;

public class ConsoleProblemCollector implements DependencyProblemCollector,HierarchyProblemCollector,EnclosedHierarchyProblemReporter {

	@Override
	public void reportNoLayer(ClassIdentifier classID) {
		System.err.println("ERROR: "+ classID +"belongs to no layer");

	}

	@Override
	public void reportProhibitedDependency(ClassIdentifier classID,
			LayerIdentifier layer, ClassIdentifier usedClassId,
			LayerIdentifier usedClassLayer) {
		System.err.println("ERROR: "+ classID +"belonging to layer "+layer+" depends on "+usedClassId+" belonging to "+usedClassLayer);

	}

	@Override
	public void reportBrokenHierarchy(ClassIdentifier classID,
			ClassIdentifier parent1, ClassIdentifier parent2) {
			System.err.println("ERROR: class "+ classID+ " has at least 2 parents: "+parent1+ " and " + parent2);
		
	}
	
	@Override 
	public void reportCycle(Collection<ClassIdentifier> allClasses) {
		
		StringBuffer classes = new StringBuffer();
		
		for(ClassIdentifier classID:allClasses) {
			classes.append("\r\n");
			
			classes.append(classID.toString());
		}
		
		System.err.println("ERROR: some classes form cycle, while shoud be hierarchical " + classes.toString());
	}

	@Override
	public void reportNoHierarchyRoot() {
		System.err.println("ERROR: no hierarchy root exists" );
		
	}

	@Override
	public void reportMultipleHierarchies(int hierarchyCount) {
		System.err.println("WARNING: more than one hierarchy found: "+hierarchyCount );
		
	}

	
	@Override
	public void reportMoreThanOneShepherd(ClassIdentifier shepherd1,
			ClassIdentifier shepherd2, ClassIdentifier sheep) {
		System.err.println("ERROR: sheep:" +sheep+" has more than one shepherds: "+shepherd1+ " and "+shepherd2 );
		
	}

	@Override
	public void reportBrokenShepherdHierarchy(
			ClassIdentifier mustBeBossShepherd,
			ClassIdentifier mustBeSubordinateShepherd,
			ClassIdentifier becauseOfThisSheep) {
		System.err.println("ERROR: shepherd "+mustBeBossShepherd+ " must be boss of the shepherd "+mustBeSubordinateShepherd+ " because of sheep " +becauseOfThisSheep+ " but he is not");
		
	}



}
